<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>FAQ | CatchAdmin 官网</title>
    <meta name="description" content="">
    <meta name="generator" content="VuePress 1.8.2">
    <style>a[title="站长统计"]{display:none}</style>
    <script data-ad-client="ca-pub-1505209242532150" async="true" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script src="https://v1.cnzz.com/z_stat.php?id=1279921342&amp;web_id=1279921342"></script>
    <meta name="description" content="基于 Thinkphp & Vue 开发的后台管理框架">
    <meta name="keywords" content="catchadmin, 后台管理, 前后端分离, thinkphp后台管理框架, thinkphp前后端分离框架,php, elementui">
    <link rel="preload" href="/assets/css/0.styles.6834c255.css" as="style"><link rel="preload" href="/assets/js/app.d0396f44.js" as="script"><link rel="preload" href="/assets/js/2.1cef47df.js" as="script"><link rel="preload" href="/assets/js/22.0a78500a.js" as="script"><link rel="prefetch" href="/assets/js/10.483f2013.js"><link rel="prefetch" href="/assets/js/11.981d4461.js"><link rel="prefetch" href="/assets/js/12.95d2c383.js"><link rel="prefetch" href="/assets/js/13.061c2fe0.js"><link rel="prefetch" href="/assets/js/14.ec2753db.js"><link rel="prefetch" href="/assets/js/15.8ba1c321.js"><link rel="prefetch" href="/assets/js/16.f7f0d34c.js"><link rel="prefetch" href="/assets/js/17.aac0bf62.js"><link rel="prefetch" href="/assets/js/18.2e2fe306.js"><link rel="prefetch" href="/assets/js/19.aee304b3.js"><link rel="prefetch" href="/assets/js/20.86a73bc1.js"><link rel="prefetch" href="/assets/js/21.8992c972.js"><link rel="prefetch" href="/assets/js/23.06342909.js"><link rel="prefetch" href="/assets/js/24.06fd96a3.js"><link rel="prefetch" href="/assets/js/25.00664d4e.js"><link rel="prefetch" href="/assets/js/26.c3d4b548.js"><link rel="prefetch" href="/assets/js/27.3c6927ad.js"><link rel="prefetch" href="/assets/js/28.74498c0b.js"><link rel="prefetch" href="/assets/js/29.aae1a826.js"><link rel="prefetch" href="/assets/js/3.4d2bdca7.js"><link rel="prefetch" href="/assets/js/30.c7732a2c.js"><link rel="prefetch" href="/assets/js/31.20403043.js"><link rel="prefetch" href="/assets/js/32.7b8e9cfe.js"><link rel="prefetch" href="/assets/js/33.8610da11.js"><link rel="prefetch" href="/assets/js/4.d7b1015b.js"><link rel="prefetch" href="/assets/js/5.ff87de2e.js"><link rel="prefetch" href="/assets/js/6.0e91e688.js"><link rel="prefetch" href="/assets/js/7.ba30e213.js"><link rel="prefetch" href="/assets/js/8.35122549.js"><link rel="prefetch" href="/assets/js/9.081b18e5.js">
    <link rel="stylesheet" href="/assets/css/0.styles.6834c255.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="ant-row"><div class="sidebar-button"><i aria-label="icon: bars" class="anticon anticon-bars"><svg viewBox="0 0 1024 1024" focusable="false" data-icon="bars" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg></i> <span></span></div> <div class="ant-col ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-5 ant-col-xl-5 ant-col-xxl-4"><a href="/" class="router-link-active no-logo home-link"><!----> <span class="site-name">CatchAdmin 官网</span></a> <div class="search-box mobile-search"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div></div> <div class="ant-col ant-col-xs-0 ant-col-sm-0 ant-col-md-18 ant-col-lg-19 ant-col-xl-19 ant-col-xxl-20"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><ul role="menu" id="nav" class="ant-menu ant-menu-horizontal ant-menu-root ant-menu-light"><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/" class="router-link-active">
          🏠首页
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/docs/">
          📖文档
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/laravel/">
          📖Laravel
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item ant-menu-item-selected"><a href="/faq/" aria-current="page" class="router-link-exact-active router-link-active">
          🤔FAQ
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/donate/">
          🎉赞助名单
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>
          🚀仓库地址
        </span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="visibility:hidden;position:absolute;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li></ul> <!----></nav></div></div> <!----></header> <aside class="sidebar"><div><div class="ads"><div id="ads_1"><img src="https://cover.kancloud.cn/akasishikelu/thinkphp6!middle"> <span title="基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析">基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析</span></div></div> <div role="separator" id="reset-margin" class="ant-divider ant-divider-horizontal ant-divider-dashed"></div></div> <!----></aside> <main class="page"> <div class="theme-antdocs-content content__default"><h2 id="faq"><a href="#faq" class="header-anchor">#</a> FAQ</h2> <h3 id="为什么项目安装成功之后无法访问"><a href="#为什么项目安装成功之后无法访问" class="header-anchor">#</a> 为什么项目安装成功之后无法访问</h3> <ul><li>安装项目之后，打开 <code>DEBUG</code>，将 <code>.env</code> 的 <code>debug</code> 设置为 <code>true</code>.</li> <li>不要直接访问 <code>PHP</code> 项目，即使你在配置完域名之后.</li></ul> <h3 id="为什么权限添加之后没有生效"><a href="#为什么权限添加之后没有生效" class="header-anchor">#</a> 为什么权限添加之后没有生效</h3> <p><code>CatchAdmin</code> 在用户登录之后，会将登录用户的权限信息缓存起来。所以需要刷新一下后台重新拉取信息。</p> <h4 id="常见错误"><a href="#常见错误" class="header-anchor">#</a> 常见错误</h4> <div class="language- extra-class"><pre class="language-text"><code>Cloud not Create token :strpos() expect parameter 1 to be string. array give
</code></pre></div><p>请检查 .env 文件是否生成了 jwt 密钥。如果没有，请执行</p> <div class="language-shell extra-class"><pre class="language-shell"><code>php think jwt:create
</code></pre></div><div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>如果还是不行，请检查是否有 .env 文件</p></div> <div class="language- extra-class"><pre class="language-text"><code>There are no commands defined in the &quot;jwt&quot; namespace.
</code></pre></div><p>解决方案有两个，均由于 Composer 升级导致的。</p> <ul><li>降低 composer 版本, <code>composer self-update --rollback</code></li> <li>升级 <code>tp</code> 核心版本，<code>composer update</code> 即可</li></ul> <blockquote><p>目前推荐第一种，防止有其他包没有做适配工作。激进点可以选择第二种，毕竟 <code>composer2</code> 太香了。</p></blockquote> <h2 id="为什么找不到-catchadmin-的-sql-文件"><a href="#为什么找不到-catchadmin-的-sql-文件" class="header-anchor">#</a> 为什么找不到 CatchAdmin 的 SQL 文件</h2> <p><code>CatchAdmin</code> 摒弃了 <code>SQL</code> 形式的安装，采用了 <code>Migration</code> 建立数据表，数据表在每个模块都是独立。
具体可以查看模块下的 <code>database</code> 文件下的 <code>migration</code>，可以清晰看到每个模块的数据表的迭代情况</p> <h2 id="如何获取登录用户的信息"><a href="#如何获取登录用户的信息" class="header-anchor">#</a> 如何获取登录用户的信息</h2> <p><code>CatchAdmin</code> 可以全局获取登录用户信息</p> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">request</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">user</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre></div><ul><li>获取用户角色</li></ul> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">request</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">user</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getRoles</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre></div><h2 id="composer-install-安装报错"><a href="#composer-install-安装报错" class="header-anchor">#</a> composer install 安装报错</h2> <p>如果遇到了 <code>think service:discover handling the post-autoload-dump event returned with error code 255</code> 错误。</p> <ul><li>如果存在 <code>composer.lock</code>, 删除 vendor 文件夹以及删除 composer.lock 文件，之后 <code>composer install</code>。</li> <li>直接 <code>composer update</code> 即可</li></ul> <h3 id="上线部署"><a href="#上线部署" class="header-anchor">#</a> 上线部署</h3> <p>优化自动加载的时候要去除 <span class="ant-tag ant-tag-orange">require-dev</span> 的加载目录</p> <div class="language- extra-class"><pre class="language-text"><code>composer dump-autoload --no-dev
</code></pre></div><h3 id="出现权限问题"><a href="#出现权限问题" class="header-anchor">#</a> 出现权限问题</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>chmod<span class="token punctuation">(</span><span class="token punctuation">)</span>: Operation not permitted
</code></pre></div><p>需要改变运行用户, 找到 fpm 运行的用户组，然后使用下面命令，<code>fpm 默认是 www-data</code>, 如果修改了用户，根据实际情况修改即可。</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">chown</span> -R www-data:www-data catch/
</code></pre></div><h3 id="出现路由为定义"><a href="#出现路由为定义" class="header-anchor">#</a> 出现路由为定义</h3> <ul><li>检查 <span class="ant-tag ant-tag-orange">runtime\catch</span> 目录下是否有缓存</li> <li>检查对应的模块是否开启,  <code>module.json</code> 文件 <span class="ant-tag ant-tag-orange">enable</span> 字段</li></ul> <h3 id="定义日期类型错误"><a href="#定义日期类型错误" class="header-anchor">#</a> 定义日期类型错误</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>Incorrect <span class="token function">date</span> value: ‘0000-00-00 00:00:00‘ <span class="token keyword">for</span> <span class="token function">column</span> ‘xxxx‘ at row <span class="token number">1</span>
</code></pre></div><p>查看 <code>sql_mode</code> 变量</p> <div class="language-sh extra-class"><pre class="language-sh"><code>show variables like <span class="token string">'%sql_mode%'</span>
</code></pre></div><p>如果含有 <code>NO_ZERO_IN_DATE</code>, <code>NO_ZERO_DATE</code>, 则去除。</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token builtin class-name">set</span> @@sql_mode<span class="token operator">=</span><span class="token string">'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'</span>
</code></pre></div><p>变量最好配置 <code>mysql</code> 的 <code>my.cnf</code> 中，否则重启会失效</p> <h2 id="模型注释无法生成"><a href="#模型注释无法生成" class="header-anchor">#</a> 模型注释无法生成</h2> <p>首先移除</p> <div class="language- extra-class"><pre class="language-text"><code>composer remove jaguarjack/file-generate --ignore-platform-reqs
</code></pre></div><p>在重新安装</p> <div class="language- extra-class"><pre class="language-text"><code>composer require jaguarjack/file-generate:dev-master --ignore-platform-reqs
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/catch-admin/document/edit/master/docs/faq/README.md" target="_blank" rel="noopener noreferrer">在 Github 编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">更新时间:</span> <span class="time">11/23/2020, 6:16:27 PM</span></div></footer> <!----> </main> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.d0396f44.js" defer></script><script src="/assets/js/2.1cef47df.js" defer></script><script src="/assets/js/22.0a78500a.js" defer></script>
  </body>
</html>